def launch_nodes(amount,known_name)
   #finding computer name in order to create the correct
   #process name for the master
   puts ("Known node name:" + known_name)
   
   for i in 1..amount
      #In case the slave file isn't already compiled
      # this sucessfully calls the test module and haha funciton
      # and provides an input parameter
      system(get_command(i.to_s,known_name))
   end
end

# name is a string that will name the erlang process
def get_command(id,name)
   return ("erl -noshell -pa ebin -sname node0"+id+" -setcookie apa -s net_adm ping_list " + name + " &")
end

# helper: determine if a string is a numeric value too
def is_numeric?(obj)
   obj.to_s.match(/\A[+-]?\d+?(\.\d+)?\Z/) == nil ? false : true
end

# the argument to pass here is
# the 
if ARGV.length != 2 || (!is_numeric? ARGV[0])
   puts "Error! Provide wanted amount of slave nodes and name of a known node."
else
   puts("Let's launch "+ARGV[0].to_s+" nodes.")

   #Here we already know it's possible to parse this 
   #input to an integer
   launch_nodes(ARGV[0].to_i, ARGV[1])
end
